#!/usr/bin/env bash

################################################################################
# Runs bazel build for proto files in cirq/google/api/*
#
# See build-changed-protos for a version of this that only builds changed
# protos.
#
# Usage:
#     check/build-protos
################################################################################

# Get the working directory to the repo root.
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$(git rev-parse --show-toplevel)"

protos=$(find -type f -name "*.proto" -printf '%P\n' \
    | grep "google/api/.*\.proto$" \
    | sed -e "s/\.proto$//")
for base in $protos:
do
    echo -e "Found proto: '${base}.proto'"
done

for base in $protos
do
    bazel build "${base}_proto"
    bazel build "${base}_py_proto"
    bazel build "${base}_cc_proto"
done
